package org.zfes.snowier.zbss.xzy.router.others;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.config.model.ConfigItemValue;
import org.zfes.snowier.zbss.xzy.biz.config.service.IConfigItemValueService;
import org.zfes.snowier.zbss.xzy.biz.dto.AIConfigItemValueDto;
@Controller 
@RequestMapping("/xzy/aIConfigItemValue")
public class AIConfigItemValueController implements BaseController {

	
	@Autowired
	private IConfigItemValueService aIConfigItemValueService;
	
    @RequestMapping(value="/loadAIConfigItemValueDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAIConfigItemValueDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  aIConfigItemValueService.loadAIConfigItemValueDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
    
    @RequestMapping(value="/loadAIConfigItemValueList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAIConfigItemValueList(Long cateId,Long deviceId){
	    List<AIConfigItemValueDto> itemValueList =  aIConfigItemValueService.loadAIConfigItemValue(cateId,deviceId);
	    return ajaxQuery("itemValueList", itemValueList);
    }
    
    
    @RequestMapping(value="/saveItemValues", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object saveItemValues(Long cateId, Long deviceId,@RequestBody List<AIConfigItemValueDto> itemValues){
	     aIConfigItemValueService.saveItemValues(cateId,deviceId,itemValues);
	     return ajaxDoneSuccess("数据操作成功 ");
    }
    
    
    
    
//    @RequestMapping(value="/createAIConfigItemValue", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
//    public  @ResponseBody Object createAIConfigItemValue(AIConfigItemValue aIConfigItemValue){
//		aIConfigItemValueService.createAIConfigItemValue(aIConfigItemValue);
//    	return ajaxDoneSuccess("数据操作成功 ");
//    }
	
    @RequestMapping(value="/loadAIConfigItemValue", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAIConfigItemValue(Long id){
		Optional<ConfigItemValue> ops = aIConfigItemValueService.loadAIConfigItemValueById(id);
		return ajaxQuery("aIConfigItemValue",ops);
    }
	
    @RequestMapping(value="/updateAIConfigItemValue", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateAIConfigItemValue(ConfigItemValue aIConfigItemValue){
		aIConfigItemValueService.updateAIConfigItemValue(aIConfigItemValue);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/deleteAIConfigItemValue", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteAIConfigItemValue(Long id){
		aIConfigItemValueService.deleteAIConfigItemValue(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}